#include <iostream>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
 
using namespace std;
const int N = 100005;
int a[N], b[N], n, tree[N];

int lowbit(int x){
	return x&(-x);
}

void add(int p){
	for(int i=p;i<=2*n;i+=lowbit(i)){
		tree[i]++;
	}
}

int sum(int p){
	int s = 0;
	for(int i=p;i>0;i-=lowbit(i)){
		s += tree[i];
	}
	return s;
}

int main(){
    int t, x;
    scanf("%d", &t);
    while(t--){
    	memset(b, 0, sizeof b);
    	memset(tree, 0, sizeof tree);
		scanf("%d", &n);
		for(int i=0;i<n;i++){
			scanf("%d", &x);
			b[x]++;
			add(x);
			if((i+1)%2 == 1){
				for(int j=0;j<N;j++){
					if(sum(j) >= i/2+1){
						printf("%d ", j);
						break;
					}
				}
			}
		}
		printf("\n");
	}
    return 0;
}
